﻿using System;
using System.IO;
using System.Windows.Forms;

namespace WindowsApplication2._7_访问数据.文件
{
    public partial class svn取消 : Form
    {
        public svn取消()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.folderBrowserDialog1.ShowDialog();
            this.textBox1.Text = this.folderBrowserDialog1.SelectedPath;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text == "")
            {
                MessageBox.Show("选择文件夹。。。");
            }

            string path = this.textBox1.Text;

            DeleteSvn(path);

            MessageBox.Show("取消成功");
        }

        private void DeleteSvn(string path)
        {
            DirectoryInfo d1 = new DirectoryInfo(path);
            //FileInfo[] f1 = d1.GetFiles();

            //foreach (FileInfo f2 in f1)
            //{
            //    if (f2.Name.IndexOf(strSearch) != -1)
            //    {
            //        ListViewItem lvItem = new ListViewItem(f2.Name, 13);

            //        lvItem.Name = f2.FullName;
            //        lvItem.SubItems.Add(f2.Length.ToString());
            //        lvItem.SubItems.Add(f2.LastWriteTime.ToShortDateString());
            //        lvItem.SubItems.Add(f2.LastWriteTime.ToShortTimeString());
            //        listView1.Items.Add(lvItem);
            //    }
            //}

            DirectoryInfo[] d2 = d1.GetDirectories();

            foreach (DirectoryInfo d3 in d2)
            {
                if (d3.Name.IndexOf(".svn") == -1)
                {
                    DeleteSvn(d3.FullName);
                }
                else
                {
                    FileCtrl.DirectoryDelete(d3.FullName);
                }
            }
        }

        private void svn取消_Load(object sender, EventArgs e)
        {

        }
    }
}